<?php
session_start();
mysql_connect("127.0.0.1","root","sd2013");
mysql_select_db("mathRomp");

echo '<html>
   <head>
      <title>View Assignments</title>
   </head>
   <body>
      <h1>View Assignments</h1>';
//Print out all compelted assignments
$q1=mysql_query("SELECT * FROM `Assignment-Teacher` WHERE teacherId=".$_SESSION['teacherId']." AND completed = 1");
while($g=mysql_fetch_assoc($q1)){
  $output[]=$g;
}
if(sizeof($output) > 0){
  echo '<b>Completed Assignments:</b>';
  for($i=0; $i<sizeof($output); $i++){
    $completed = json_decode(json_encode($output[$i]));
    echo '<li>'.$completed->assignmentName.'</li>';
  }
  echo '<br />';
}

//Print out incomplete assignments
$q2=mysql_query("SELECT * FROM `Assignment-Teacher` WHERE teacherId=".$_SESSION['teacherId']." AND completed = 0");
while($e=mysql_fetch_assoc($q2)){
  $output2[]=$e;
}
if(sizeof($output2) > 0){
  echo '<b>Incomplete Assignments:</b>';
  for($i=0; $i<sizeof($output2); $i++){
    $incomplete = json_decode(json_encode($output2[$i]));
    echo '<li>'.$incomplete->assignmentName.'</li>';
  }
  echo '<br />';
}


echo '<a href="http://localhost/mathRomp/teacherHome.html">Home</a>
   </body>
</html>';